#include "GhostEntity.h"
#include "Application.h"
#include "ConfigurationManager.h"
#include <iostream>

#define AnimationIndex_Max 3
#define AnimationTickInterval 5


GhostEntity::GhostEntity(void)
{
	Initialize();
}

GhostEntity::GhostEntity(int pX, int pY)
{
	_X = pX;
	_Y = pY;
	Initialize();
}

GhostEntity::~GhostEntity(void){}

void GhostEntity::Think()
{
	_IndexAnimation.Tick();
}

void GhostEntity::Draw(sf::RenderWindow &pRenderWindow)
{
	_Sprite.SetPosition((float)_X, (float)_Y);
	_Sprite.SetSubRect(sf::IntRect(_IndexAnimation.Index()*Conf_LevelElementSize,0,(_IndexAnimation.Index()+1)*Conf_LevelElementSize,Conf_LevelElementSize));
	pRenderWindow.Draw(_Sprite);
}

void GhostEntity::Initialize()
{
	_Sprite.SetImage(Application::Instance().ImageManager().GetImage(Ghost));
	_Sprite.SetBlendMode(sf::Blend::Alpha);
	_IndexAnimation.Create(0, AnimationIndex_Max, RepeatFlip, AnimationTickInterval);
}